/*
package com.exeample.appium;

import com.exeample.appium.utils.OperationUtils;
import io.appium.java_client.android.AndroidDriver;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;

import java.util.Set;

@Slf4j
public class IphtsccftAppium {
    //设备号
    public static String deviceName;
    public static AndroidDriver driver;

/*    static {
        try {
            driver =OperationUtils.getPropertiesByInputStream_Four();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args){
        try{
            setLogin("666630718960","641288","86689731");
            intoDaXin();
        }catch (Exception e){
            System.out.println("出现异常！"+e.getMessage());
            e.printStackTrace();
        }
    }*/



/**
     * 账户登录
     * @param accountEdit 客户号
     * @param passwordEdit 交易密码
     * @param shieldPasswordEdit 通讯密码
     *//*

    public static void setLogin(String accountEdit, String passwordEdit, String shieldPasswordEdit){
        log.info("setLogin ... accountEdit={},passwordEdit={},shieldPasswordEdit={}",accountEdit,passwordEdit,shieldPasswordEdit);
        try{
            //延时2秒
            OperationUtils.delay(driver, 2);
            driver.findElement(By.name("跳过")).click();
            //第一次进打新提醒X掉
            boolean dialogIvCancel =OperationUtils.isIdShow(driver,By.id("com.lphtsccft:id/dialog_iv_cancel"));
            if(dialogIvCancel){
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/dialog_iv_cancel");
            }
            //点击我的
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/rb_mine");
            //第一次进入我的页面-有无提醒图
            boolean layout =OperationUtils.isIdShow(driver,By.id("com.lphtsccft:id/iv_advertisement_layout"));
            if(layout){
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/iv_advertisement_layout");
            }

            //是否是第一次登录-立即登录或开户
            boolean trade_login_hint =OperationUtils.isIdShow(driver,By.id("com.lphtsccft:id/trade_login_hint"));
            if(trade_login_hint){
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/trade_login_hint");
                //点击已有客户号
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/have_account_layout");
                //点击确定
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/confirm_text_view");
                //请输入手机号
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/phone_num_edit");
                WebElement weOne = driver.findElement(By.id("com.lphtsccft:id/phone_num_edit"));
                weOne.sendKeys("18309864917");
                //获取验证码
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/tv_verify");
                //输入验证码
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/verification_edit");
                WebElement weTwo = driver.findElement(By.id("com.lphtsccft:id/verification_edit"));
                weTwo.sendKeys("888888");
                //验证
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/confirm_text_view");
            }

            //进入账户
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/weak_mine_loginwithtrade_logined");
            //切换账户
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/login_account_list");
            //添加账户
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/change_account_text_view");
            //交易登录
            */
/* List<WebElement> elements = driver.findElementsByClassName("android.widget.EditText");
                elements.get(0).sendKeys("666630718960  ");
                elements.get(1).sendKeys("641288  ");
                elements.get(2).sendKeys("86689731");*//*

            //客户号
            driver.findElement(By.name("请输入华泰客户号")).click();
            WebElement weOne = driver.findElement(By.id("com.lphtsccft:id/account_edit"));
            weOne.sendKeys(accountEdit);
            //交易密码
            driver.findElement(By.name("请输入交易密码")).click();
            WebElement weTwo = driver.findElement(By.id("com.lphtsccft:id/password_edit"));
            weTwo.sendKeys(passwordEdit);
            //通讯密码
            driver.findElement(By.name("请输入通讯密码")).click();
            driver.findElementByName("请输入通讯密码").sendKeys(shieldPasswordEdit);
            //driver.findElementById("com.lphtsccft:id/shield_password_edit").sendKeys(shieldPasswordEdit);
            //WebElement weThree = driver.findElement(By.id("com.lphtsccft:id/shield_password_edit"));
            //weThree.sendKeys(shieldPasswordEdit);
            //登录
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/confirm_text_view");
            //第一次成功进入我的账户-有无提醒图
            boolean layoutMain =OperationUtils.isIdShow(driver,By.id("com.lphtsccft:id/iv_advertisement_layout"));
            if(layoutMain){
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/iv_advertisement_layout");
            }
            //系统提示-确认
            boolean dialogBtnLeft =OperationUtils.isIdShow(driver,By.id("com.lphtsccft:id/dialog_btn_left"));
            if(dialogBtnLeft){
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/dialog_btn_left");
            }
            //是否出现系统提示，操作失误时
            boolean dialogTvTitle =OperationUtils.isIdShow(driver,By.id("com.lphtsccft:id/dialog_tv_title"));
            if(dialogTvTitle){
                String dialogTvMessage =driver.findElement(By.id("com.lphtsccft:id/dialog_tv_message")).getText();
                System.out.println(dialogTvMessage);
                OperationUtils.findAndClick(driver, "com.lphtsccft:id/dialog_btn_left");
            }
            log.info("setLogin ... successfull");
        }catch (Exception e){
            System.out.println("setLogin 出现异常！"+e.getMessage());
            e.printStackTrace();
        }
    }

    */
/**
     * 进入打新神器
     *//*

    public static void intoDaXin() {
        try{
            //交易
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/rb_trade");
            //打新神器
            driver.findElement(By.name("打新神器")).click();
            boolean explanatio =OperationUtils.isIdShow(driver,By.name("今日暂无新债发行"));
            if(explanatio){
                System.out.println("今日暂无新债发行");
            }
            Thread.sleep(3);
            OperationUtils.delay(driver, 6);
            System.out.println("当前环境:"+driver.getContextHandles());
            // 用于返回被测app是NATIVE_APP还是WEBVIEW，如果两者都有就是混合型App
            Set<String> contextNames = driver.getContextHandles();
            for (String contextName : contextNames) {
                if(contextName.contains("WEBVIEW")){
                    // 让appium切换到webview模式以便查找web元素
                    driver.context(contextName);
                    System.out.println("切换到webview："+contextName);
                    System.out.println("移动端混合型APP ==>"+contextName);
                }else{
                    System.out.println("移动端原生型APP ==>"+contextName);
                }
            }

            WebElement text_baidusearch = driver.findElement(By.id("html"));
            System.out.println(text_baidusearch);
            text_baidusearch.click();// 点击百度的搜索输入框（web元素）

            */
/*
             * appium不支持中文输入 参考了robotium的以js方式为元素直接设置value的做法
             * 利用Selenium中Webdriver执行js方法实现中文输入
             *//*

            JavascriptExecutor jse = driver;
            jse.executeScript("document.getElementById('word').value='输入法'");

            OperationUtils.delay(driver, 200);



            //查询我的申购
            driver.findElement(By.name("查询我的申购")).click();
            //我的申购后退
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/title_bar_left");
            //新债申购
            driver.findElement(By.name("新债申购")).click();
            //新债申购后退
            OperationUtils.findAndClick(driver, "com.lphtsccft:id/title_bar_left");
            log.info("tearDown ... successfull");
        }catch (Exception e){
            System.out.println("intoDaXin 出现异常！"+e.getMessage());
            e.printStackTrace();
        }
    }

    */
/**
     * 退出
     *//*

    public void tearDown() {
        if (driver != null) {
            driver.quit();
        }
        log.info("tearDown ... successfull");
    }

}
*/
